//
//  label.m
//  Void Dead
//
//  Created by Sidney Just on 25.08.09.
//  Copyright 2009 Sidney Just
//  This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; 
//  either version 3 of the License, or (at your option) any later version.
//  
//  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 
//  of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
//  

#import "label.h"


@implementation VD_label
@synthesize pos_x, pos_y;
@synthesize textColor, visible, size_x, size_y;

- (id)init {
	if(self = [super init])
	{
		pos_x = 0;
		pos_y = 0;
		
		textString = [[NSString alloc] init];
		textColor = [[VD_Color alloc] init];
		
		textColor.alpha = 1;
		textColor.red = 1;
		textColor.green = 1;
		textColor.blue = 1;
		
		size_x = 0;
		size_y = 0;
		
		visible = YES;
	}
	return self;
}

- (void)dealloc {
	[textString release];
	[textColor release];
	
	[super dealloc];
}

- (void)drawLabel:(VD_Engine *)eng {
	[text drawAtPoint:CGPointMake(pos_x, eng.backingHeight-pos_y-size_y)];
}

- (void)setString:(NSString *)str fontName:(NSString*)name fontSize:(CGFloat)size {
	if(text != NULL)
		[text release];
	
	[textString release];
	textString = [[NSString alloc] initWithString:str];
		
	text = [[Texture2D alloc] initWithString:str fontName:name fontSize:size];
	
	size_x = text.contentSize.width;
	size_y = text.contentSize.height;
}

@end
